﻿using Mes.Domain.BoundedContext.Entities.Operations;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Mes.Domain.BoundedContext.Entities.WorkOrders;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.WorkOrders
{
    public class JobRouteEntityConfig : IEntityTypeConfiguration<JobRoute>
    {
        public void Configure(EntityTypeBuilder<JobRoute> builder)
        {
            builder.ToTable("job_route");
            builder.Property(e => e.Wo_Id).IsRequired();
            builder.Property(e => e.Oper_Id).IsRequired();
            builder.Property(e => e.Input_Oper_Id).IsRequired();
            builder.HasKey(b => new { b.Wo_Id, b.Oper_Id, b.Input_Oper_Id});
            builder.Property(e => e.Input_Percent).IsRequired();
            builder.Property(e => e.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(e => e.Last_Edit_By).HasMaxLength(40);
            builder.Property(e => e.Last_Edit_At).IsRequired();
            builder.Property(e => e.Mod_Id).IsRequired();
            builder.Property(e => e.Row_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
